/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iwords.ejb;

import com.iwords.service.object.UserEntity;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author sunmellon
 */
@Stateless
public class UserEntityFacade extends AbstractFacade<UserEntity> {
    @PersistenceContext(unitName = "iwords")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public UserEntityFacade() {
        super(UserEntity.class);
    }
    
    public UserEntity findByUsername(String username){
        UserEntity user = (UserEntity)getEntityManager()
                .createQuery("SELECT i FROM UserEntity i WHERE i.username = :username")
                .setParameter("username", username)
                .getSingleResult();
        //System.out.println("TeacherEntityFacade.findByname() teacher.getStudents()="+teacher.getStudents());
        return user;
    }
}
